#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include"weatherdata.h"
#include<QLabel>
#include<QMouseEvent>
#include <QMainWindow>
#include<QNetworkAccessManager>
#include<QNetworkReply>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    //右键处理事件
    void contextMenuEvent(QContextMenuEvent *event);
    //获取指针偏移量
    void mousePressEvent(QMouseEvent* event);
    //实现窗口随指针移动
    void mouseMoveEvent(QMouseEvent* event);
    //获取天气数据
    void getWeatherInfo(QString citycode);
    //解析数据
    void parseJson(QByteArray& byteArray);
    //更新UI
    void updateUI();

    //重写父类的eventfilter方法
    bool eventFilter(QObject* watched,QEvent* event);

    //绘制高低温曲线
    void paintHighCurve();
    void paintLowCurve();

private:
    void onReplied(QNetworkReply* reply);

private:
    Ui::MainWindow *ui;
    //构建右键菜单
    QMenu* mExitMenu;
    QAction* mExitAct;
    //鼠标相对于窗口的偏移量
    QPoint mOffSet;
    //http请求
    QNetworkAccessManager* mNetAccessManager;

    //今天和六天的天气
    Today mToday;
    Day mDay[6];

    //星期和日期
    QList<QLabel*> mWeekList;
    QList<QLabel*> mDateList;

    //天气和天气图标
    QList<QLabel*> mTypeList;
    QList<QLabel*> mTypeIconList;

    //天气污染指数
    QList<QLabel*> mAqiList;

    //风力和风向
    QList<QLabel*> mFlList;
    QList<QLabel*> mFxList;

    QMap<QString,QString> mTypeMap;
};
#endif // MAINWINDOW_H
